import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Window 2.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1




Window {
    id: mainWindow
    title: "Settings"
    flags: Qt.Dialog
    width: 400
    height: 640

    signal notifyChanged(string notify)
    signal defaultIntervalChanged(int interval)
    signal backPressed

    property int controlsWidth: 100

    Rectangle {
        id: mainRect
        color: "#f4f4f4"
        anchors.fill: parent
        focus: true

        Header {
            id: header
            iconSource: "qrc:images/settings2.png"
            title: "Settings"
        }

        Item {
            id:leftItem
            anchors.top: header.bottom
            width: 32
        }

        Item {
            id: mainItem
            anchors.top: header.bottom
            anchors.left: leftItem.right


            GridLayout
            {
                id: gridLayout
                anchors.horizontalCenter: parent.Center
                columns: 2

                Label {
                    id: notifyLb
                    font.pixelSize: 26
                    text: "Notify:"
                }

                ComboBox {
                    id: notifyCB
//                    anchors.left: notifyLb.right
//                    anchors.right: sItem.right
                    width: mainWindow.controlsWidth
                    currentIndex: 0
                    model: ListModel {
                        id: notifyItems
                        ListElement { text: "None" }
                        ListElement { text: "Sounds" }
                        ListElement { text: "Vibes" }
                        ListElement { text: "Sounds & Vibes" }
                    }

                    onCurrentTextChanged: {
                        notifyChanged(currentText)
                    }
                }

                Label {
                    font.pixelSize: 26
                    text: "Default interval:"
                }

                SpinBox {
                    id: intervalSB
                    width: mainWindow.controlsWidth
                    minimumValue: 1
                    maximumValue: 999999999
                    value: 1
                    suffix: " min"

                    onValueChanged: defaultIntervalChanged(value)
                }
            }
        }
        Keys.onReleased: {
            if ( event.key === Qt.Key_Back && visible )
            {
                console.log("Back button captured - wunderbar !")
                event.accepted = true
                backPressed()
            }
        }
    }
}
